package com.zte.moon.yutu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 14-1-7
 * Time: 下午9:48
 * To change this template use File | Settings | File Templates.
 */
public class MoonApp {


    public static void main(String[] args) throws IOException {
        Area area = new Area(new Point(0,0),new Point(5 ,5));
        Point point = new Point(1,1);
        Detector detector = new Detector();
        ControlCenter controlCenter = new ControlCenter();

        String code;
        BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

        System.out.println("Input area:");
        code = buff.readLine();
        while (!Pattern.compile("NRS").matcher(code).matches())
        {
            System.out.print("ERROR!");
            System.out.println("Input area:");
            code = buff.readLine();
        }
        controlCenter.setArea(code, area);

        System.out.println("Input load:");
        code = buff.readLine();
        while (!Pattern.compile("NRS").matcher(code).matches())
        {
            System.out.print("ERROR!");
            System.out.println("Input load:");
            code = buff.readLine();
        }
        controlCenter.loadDetector(code, detector, area);

        System.out.println("Input command:");
        code = buff.readLine();
        while (!Pattern.compile("NRS").matcher(code).matches())
        {
            System.out.print("ERROR!");
            System.out.println("Input command:");
            code = buff.readLine();
        }
        controlCenter.sendCommand(code, detector);

        System.out.println();
        System.out.println("Output:");
        System.out.println(detector.toString());
    }

}
